.BG
.FN Assignment
.FN _
.FN ->
.FN <<-
.FN <-
.TL
Assignment
.CS
expression <- value
expression _ value
value -> expression

expression <<- value
.PP
If `expression' is a name,
the assignment operator, in any of its forms, causes the value of
`value' to be saved under that name.  Note
that the arrow always points toward the name.  The left-arrow is made up
of the two characters `<' and `-'.  An underscore, `_', can also be
used for left-arrow.  Right-arrow is the two characters `-' and `>'.
All three of these are equivalent semantically, and are referred to as
`\(<-' throughout the book.
.PP
The `expression' can also specify a subset, element, or attribute of an
object, or any combination of such expressions.
Expressions of this form are called replacements, to distinguish
them from simple assignments.
Examples include:
.Cs
x[-1] <- 0
length(mystuff) <- n
z$b <- 3
attr(obj,"myattr")[[1]] <- new.value
.Ce
Once an assignment is made, the data can be retrieved
(in the same frame) by mentioning
the name used in the assignment.  The value of the assignment (when
used as an expression) is the value of the right-hand side.
Notice that this is true for replacements as well; the value of a
replacement is the substituted values, not the whole object in which the
replacement occurs.
.PP
Assignments with `\(<-' take place in the frame of the function call in which they
occur, or in the working directory if they occur in frame 1.
Replacements taking place in frame 1 take place in the frame in which the
object was found (the working directory, frame 1 or frame 0).  They will
create the corresponding object in the working directory if it was found
somewhere else.  For example, if there is no current object `iris' in the
working directory,
.Cs
dim(iris) \(<- c(50,12)
.Ce
will create one.
The `<<-' operator always does
assignments and replacements on the working data directory, from any frame.
.PP
Assignments are committed when S finishes evaluating an entire
expression.  If an error occurs during evaluation of an expression,
no assignments executed during that expression are committed.
.SA
`assign', `remove', `get', `exists', `attach', `detach', `search', `synchronize'.
.EX
y <- sqrt( x<-runif(100) )      # 100 uniforms saved as x
          # square root of sample saved under the name y
.KW data
.KW manip
.WR
